<template>
  <div class="add" style="position: fixed; top: 0; width: 100%; height: 2000px; background: white">
    <div style="width: 100%;height: 55px;background: white;display: flex" @click="fanhui">
      <div style="font-family: 'Avenir';font-size: 25px;margin: 15px 0 20px 20px"><van-icon name="arrow-left" /></div>
    </div>
    <div style="width: 85%;height: 180px;margin: 30px 0 0 30px;background: white">
      <div style="font-size: 35px; text-align: left;">设置支付密码</div>
      <div style=" font-size: 16px; text-align: left;display: flex;color: darkgray">
        设置小默盒子管家的支付密码，用于支付验证</div>
    </div>
    <div style="width: 85%;height: 300px;margin: 0px 0 0 30px;background: white">
      <!-- 输入手机号，调起手机号键盘 -->
      <!-- 密码输入框 -->
      <van-password-input
          :value="value"
          :focused="showKeyboard"
          @focus="showKeyboard = true"
      />
      <!-- 数字键盘 -->
      <van-number-keyboard
          v-model="value"
          :show="showKeyboard"
          @blur="showKeyboard = false"
      />
      <van-button type="primary" style="width: 100%; height: 45px; background: #51b8ff;
     border: white; font-size: 18px; margin-top: 40px; border-radius:50px;" @click="phoneUpdate">确定</van-button>
    </div>

  </div>

</template>

<script>
import { ref } from 'vue';

import {userPhoneUpdate ,userPasswordUpdate , userPayPasswordUpdate, Delete, yzm} from "@/api/SetUp/AccountSafe/accountSafa"

export default {
  setup() {
    const value = ref('');
    const showKeyboard = ref(true);

    return {
      value,
      showKeyboard,
    };
  },
  data() {
    return {
      yzm:'',
      count:0,
      user:JSON.parse(localStorage.getItem('login')),
      user2:{},
    };
  },
  created() {
    this.query=this.$route.query;
  },
  methods: {
    fanhui(){
      this.$router.push('/accountSafe')
    },
    phoneUpdate(){
      this.user.payPassword=this.value
      userPayPasswordUpdate(this.user).then(row => {
        this.user2=this.user
        localStorage.removeItem("login");
        localStorage.setItem('login', JSON.stringify(this.user2));
          this.$toast('修改成功');
          this.$router.push('/accountSafe')

      })
    },

  },
};
</script>

<style scoped>

</style>
